package com.hpradip.android.documentaryHub;

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class FeedsAdapter extends ArrayAdapter<DocumentaryFeed> {

	private List<DocumentaryFeed> items;
	private LayoutInflater inflater;
	private Context context;

	public FeedsAdapter(Context context, int textViewResourceId,
			List<DocumentaryFeed> objects) {
		super(context, textViewResourceId, objects);
		this.items = objects;
		this.inflater = LayoutInflater.from(context);
		this.context = context;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if (v == null) {
			v = inflater.inflate(R.layout.list_item, null);
		}
		DocumentaryFeed feed = items.get(position);
		if (feed == null)
			return v;

		TextView header = (TextView) v.findViewById(R.id.header);
		header.setText(feed.getTitle());

		TextView desc = (TextView) v.findViewById(R.id.description);
		desc.setText(feed.getDescription());

		TextView date = (TextView) v.findViewById(R.id.date);
		date.setText(feed.getDate());

		ImageView img = (ImageView) v.findViewById(R.id.image_thumb);
		img.setImageDrawable(feed.getImageThumb());
//		View view = v.findViewById(R.id.button_more);
//		TextView moreButton = (TextView) view;
//		moreButton.setOnClickListener(new FeedClickListener(feed));
		return v;
	}

	

}
